package com.ctsi.framework.mybatis.dialect;

import java.sql.PreparedStatement;
import java.sql.SQLException;

/**
 * Gbase数据库方言实现
 * @author zhangjw
 *
 */
public class GbaseDialect extends AbstractMiDialect {


	@Override
	public void setLimitParamters(PreparedStatement ps, int parameterSize,
			int offset, int limit) throws SQLException {
		if(offset > 0){
			ps.setInt(parameterSize + 1, offset);
			ps.setInt(parameterSize + 2, limit);
		}else{
			ps.setInt(parameterSize + 1, limit);
		}
		
	}

	@Override
	public String getLimitString(String sql, int offset) {
		return new StringBuilder( sql.length()+20 )
		.append(sql)
		.append( offset > 0 ? " limit ? , ?" : " limit ?")
		.toString();
	}

	@Override
	public boolean supportsLimitOffset() {
		
		return true;
	}

}
